<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Db;
use \think\Loader;
class Login extends Controller
{
    public function index()
    {
        return $this->fetch('',[]);
    }

    public function login(){
    	$data=input('post.');
    	$data['password']=md5($data['password']);
        $res = Db::table('admin')->where($data)->find();

        if($res){
			session('aid',$res['aid']);
			session('adminname',$res['name']);
			return ['error'=>0,'info'=>'登录成功','url'=>url('admin/index/index')];
		}else{
			return ['error'=>1,'info'=>'邮箱或者密码错误'];
		}
    }

    public function loginOut(){
    	session(null);
    	$this->success('退出成功', 'admin/login/index');
    }

}


?>